/*
 * hfsset.h - configure handsfree
 *
 * Copyright (C) 2010-2011 Serge Begger
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef HFSSET_H
#define HFSSET_H

#include <QWidget>
#include <QSettings>
#include "bluez/manager.h"
#include "bluez/adapter.h"
#include "bluez/agent.h"
#include "bluez/manageragent.h"
#include "qcarpcdialog.h"

namespace Ui {
    class hfsset;
}

class hfsset : public QWidget
{
    Q_OBJECT

public:
    explicit hfsset(QWidget *parent = 0);
    bool btActive;
    ~hfsset();

signals:
    void connectDevice();
    void disconnectDevice();

private:
    Ui::hfsset *ui;
    QSettings *settings;
    QString currDevName;
    QString currDevAddr;
    bool currDevConn;
    QString adapterPath;
    numPanel *pinPanel;
    OrgBluezAdapterInterface *adapter;
    OrgBluezManagerInterface *manager;

    bool initBT();
    bool deviceIsConnected();

private slots:
    void changeDev(int index);
    void addBTDevice(const QString &address, const QVariantMap &values);
    void pairedFinished(QDBusPendingCallWatcher *watcher);
    void on_updateDevices_pressed();
    void on_connectDevice_pressed();
    void on_disconnectDevice_pressed();
    void pairedDevice();
};

#endif // HFSSET_H
